home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 January / PC Plus Super CD No55a (PCP-147A-1-99) (Disc 1) (1998).iso / linux / developers / visualtcl / windows / vtcl / lib / handle.tcl < prev    next >
Encoding:
Text File  |  1997-04-09  |  3.5 KB  |  95 lines

  1. ##############################################################################
  2. # $Id: handle.tcl,v 1.2 1997/04/09 13:13:02 stewart Exp $
  3. #
  4. # handle.tcl - procedures to manipulate widget handles
  5. #
  6. # Copyright (C) 1996-1997 Stewart Allen
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License
  10. # as published by the Free Software Foundation; either version 2
  11. # of the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. ##############################################################################
  23. #
  24.  
  25. proc vTcl:destroy_handles {} {
  26.     global vTcl
  27.     if { $vTcl(h,exist) == "yes" && [winfo exists $vTcl(h,n)] == 1} {
  28.         destroy $vTcl(h,n) $vTcl(h,e)
  29.         destroy $vTcl(h,s) $vTcl(h,w) 
  30.         destroy $vTcl(h,nw) $vTcl(h,ne)
  31.         destroy $vTcl(h,se) $vTcl(h,sw) 
  32.     }
  33.     set vTcl(h,exist) no
  34. }
  35.  
  36. proc vTcl:create_handles {target} {
  37.     global vTcl
  38.     if { $vTcl(h,exist) == "yes" } {
  39.         vTcl:destroy_handles
  40.     }
  41.     if { $vTcl(w,manager) == "wm" || $target == "." } { return }
  42.     set vTcl(h,exist) yes
  43.     set s [expr $vTcl(h,size) * 2]
  44.     set parent [winfo parent $target]
  45.     if { $parent == "." } { set parent "" }
  46.  
  47.     foreach i { {n top_tee} {s bottom_tee} {e right_tee} {w left_tee} \
  48.                 {nw ul_angle} {ne ur_angle} {sw ll_angle} {se lr_angle} } {
  49.         set a [lindex $i 0]
  50.         set b [lindex $i 1]
  51.         set vTcl(h,$a) "$parent.vTH_${a}"
  52.         frame $vTcl(h,$a) \
  53.             -width $s -height $s -bg gray30 -bd 0 -relief flat \
  54.             -highlightthickness 0 -cursor $b
  55.         bind $vTcl(h,$a) <B1-Motion>       "vTcl:grab_resize %X %Y $a"
  56.         bind $vTcl(h,$a) <Button-1>        "vTcl:grab %W %X %Y"
  57.         bind $vTcl(h,$a) <ButtonRelease-1> "vTcl:grab_release %W"
  58.     }
  59.     vTcl:place_handles $target
  60. }
  61.  
  62. proc vTcl:place_handles {target} {
  63.     global vTcl
  64.     if {$target == ""} {return}
  65.     if {$vTcl(h,exist) == "yes" && [winfo exists $vTcl(h,n)]} {
  66.         update idletasks
  67.         set s $vTcl(h,size)
  68.         set x [winfo x $target]
  69.         set y [winfo y $target]
  70.         set w1 [winfo width $target]
  71.         set w2 [expr $w1 / 2]
  72.         set h1 [winfo height $target]
  73.         set h2 [expr $h1 / 2]
  74.         place $vTcl(h,n)  \
  75.             -x [expr $x + $w2 - $s] -y [expr $y - $s]       -bordermode ignore
  76.         place $vTcl(h,e)  \
  77.             -x [expr $x + $w1 - $s] -y [expr $y + $h2 - $s] -bordermode ignore
  78.         place $vTcl(h,s)  \
  79.             -x [expr $x + $w2 - $s] -y [expr $y + $h1 - $s] -bordermode ignore
  80.         place $vTcl(h,w)  \
  81.             -x [expr $x - $s]       -y [expr $y + $h2 - $s] -bordermode ignore
  82.         place $vTcl(h,nw) \
  83.             -x [expr $x - $s]       -y [expr $y - $s]       -bordermode ignore
  84.         place $vTcl(h,ne) \
  85.             -x [expr $x + $w1 - $s] -y [expr $y - $s]       -bordermode ignore
  86.         place $vTcl(h,se) \
  87.             -x [expr $x + $w1 - $s] -y [expr $y + $h1 - $s] -bordermode ignore
  88.         place $vTcl(h,sw) \
  89.             -x [expr $x - $s]       -y [expr $y + $h1 - $s] -bordermode ignore
  90.     } else {
  91.         vTcl:create_handles $target
  92.     }
  93. }
  94.  
  95.